package com.fayou.cloud.cloudconsumeropenfeignorder8082.service;

import com.fayou.cloud.cloudconsumeropenfeignorder8082.fallback.FeignPaymentServiceFallback;
import com.fayou.cloud.cloudconsumeropenfeignorder8082.fallback.FeignPaymentServiceFallbackFactory;
import com.fayou.cloud.entites.CommonResult;
import com.fayou.cloud.entites.Payment;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Service
@FeignClient(value = "CLOUD-PAYMENT-SERVICE", fallbackFactory = FeignPaymentServiceFallbackFactory.class, path = "payment")
//@FeignClient(value = "CLOUD-PAYMENT-SERVICE",fallback = FeignPaymentServiceFallback.class)
//@RequestMapping("/payment")
public interface FeignPaymentService {
    @GetMapping("/selectOne")
    public CommonResult selectOne(@RequestParam(required = false, value = "id") Integer id);


    /**
     * 注意和服务提供者完全一致，注意大小写
     *
     * @return
     */
    @GetMapping("/timeout")
    public String paymentFeignTimeout();


    @GetMapping("/hystrix/ok/{id}")
    public String paymentInfo_OK(@PathVariable("id") Integer id);

    @GetMapping("/hystrix/timeout/{id}")
    public String paymentInfo_TimeOut(@PathVariable("id") Integer id);

    //====服务熔断
    @GetMapping("/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id);
}
